<?php

namespace addons\teacherdisplay;
use app\common\controller\Addon;

/**
 * 次级教师展示栏插件
 * @author li
 */

    class Teacherdisplay extends Addon{

        public $info = array(
            'name'=>'teacherdisplay',
            'title'=>'次级教师展示栏',
            'description'=>'用于第二首页的次级教师展示栏',
            'status'=>1,
            'author'=>'li',
            'version'=>'0.1'
        );

        public function install(){
            return true;
        }

        public function uninstall(){
            return true;
        }

        //实现的secondIndex钩子方法
        public function secondIndex($lists){
            $config = $this->getConfig();
            if($config['display']){
                $this->model_id = \think\Db::name('model')->where('title',$config['model'])->find();
                $this->model_id = $this->model_id['id'];
                $lists = array_filter($lists['lists'],function ($var){return($var['model_id']==$this->model_id);});
                $this->assign('config',$config);
                $this->assign('model_id',$this->model_id);
                $this->assign('lists',$lists);
                $this->fetch('contain');
            }
        }

    }